<html>
<head><meta charset="utf-8"><title>upvar path · t-compiler/wg-rfc-2229 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/index.html">t-compiler/wg-rfc-2229</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html">upvar path</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160498220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160498220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160498220">(Mar 11 2019 at 17:14)</a>:</h4>
<p><span class="user-mention" data-user-id="128294">@blitzerr</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> would it be ok if I started taking a look at Step 3 of the <a href="https://paper.dropbox.com/doc/RFC-2229-Roadmap-cJKrePDCZR54T5kVbuoQk" target="_blank" title="https://paper.dropbox.com/doc/RFC-2229-Roadmap-cJKrePDCZR54T5kVbuoQk">Roadmap</a> since it's kinda orthogonal? lots to learn there for me, I guess</p>



<a name="160499776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160499776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> blitzerr <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160499776">(Mar 11 2019 at 17:31)</a>:</h4>
<p>Is there a sub section (A, B, ..) that particularly interests you in step 3 ?</p>



<a name="160500699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160500699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160500699">(Mar 11 2019 at 17:44)</a>:</h4>
<p>B and C I guess?</p>



<a name="160500764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160500764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160500764">(Mar 11 2019 at 17:44)</a>:</h4>
<p>B if I had to choose</p>



<a name="160500950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160500950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> blitzerr <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160500950">(Mar 11 2019 at 17:47)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="160954668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160954668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160954668">(Mar 16 2019 at 14:59)</a>:</h4>
<p>OK, so, this is positively infested with FIXMEs, but, for this source:</p>
<div class="codehilite"><pre><span></span><span class="cp">#![feature(rustc_attrs)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Quux</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">z</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">w</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Bar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">quux</span>: <span class="nc">Quux</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">(</span><span class="k">mut</span><span class="w"> </span><span class="n">cl</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="nc">where</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnMut</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">cl</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[rustc_dump_closure_captures]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">6</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">bar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">quux</span>: <span class="nc">Quux</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">z</span>: <span class="mi">9</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">w</span>: <span class="mi">10</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">},</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span><span class="p">(</span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">y</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">bar</span><span class="p">.</span><span class="n">quux</span><span class="p">.</span><span class="n">w</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">bar</span><span class="p">.</span><span class="n">quux</span><span class="p">.</span><span class="n">z</span><span class="w"></span>
<span class="w">    </span><span class="p">});</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>I now get</p>
<div class="codehilite"><pre><span></span>error: closure capture paths: Upvar local mut y (id=53) [&quot;Deref Deref&quot;]
  --&gt; example-annotated.rs:25:9
   |
25 |       foo(|| {
   |  _________^
26 | |         y += 1;
27 | |         x + y + bar.quux.w + bar.quux.z
28 | |     });
   | |_____^

error: closure capture paths: Upvar local bar (id=56) [&quot;Deref Deref Field(quux) Field(w)&quot;, &quot;Deref Deref Field(quux) Field(z)&quot;]
  --&gt; example-annotated.rs:25:9
   |
25 |       foo(|| {
   |  _________^
26 | |         y += 1;
27 | |         x + y + bar.quux.w + bar.quux.z
28 | |     });
   | |_____^

error: closure capture paths: Upvar local x (id=50) [&quot;Deref Deref&quot;]
  --&gt; example-annotated.rs:25:9
   |
25 |       foo(|| {
   |  _________^
26 | |         y += 1;
27 | |         x + y + bar.quux.w + bar.quux.z
28 | |     });
   | |_____^

error: aborting due to 3 previous errors
</pre></div>



<a name="160954750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160954750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160954750">(Mar 16 2019 at 15:00)</a>:</h4>
<p>(this is by walking the <code>cmt_</code> linked-list in <code>adjust_upvar_borrow_captures_for_consume</code> FWIW)</p>



<a name="160954820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160954820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160954820">(Mar 16 2019 at 15:02)</a>:</h4>
<p>Will need to take a close look at the usage of <code>NoteClosureEnv</code> and <code>NoteUpvarRef</code> to get rid of the synthetic Derefs</p>



<a name="160954911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/160954911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#160954911">(Mar 16 2019 at 15:05)</a>:</h4>
<p><span class="user-mention" data-user-id="128294">@blitzerr</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> FWIW, it doesn't seem viable to keep the paths in <code>UpvarId</code> (needs to be <code>Copy</code>). Currently, I just added a separate map from <code>UpvarId</code> -&gt; paths</p>



<a name="161092055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161092055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161092055">(Mar 18 2019 at 20:13)</a>:</h4>
<p>Oh, nice</p>



<a name="161461243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461243">(Mar 22 2019 at 16:09)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> since you're answering questions... I'm doing some exploratory coding trying to reuse the <code>cmt_</code> machinery to track paths to accesses. one issue is that, when there's indexing, you get a <code>Categorization::Rvalue</code> that you can't look past (so that e.g. you can tell that when you have <code>foo.bar[x].quux</code>, the capture path is <code>foo.bar</code>. I'm looking into extending the <code>Rvalue</code> to record the "base" <code>cmt_</code>, not sure if that's the best approach?</p>



<a name="161461322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461322">(Mar 22 2019 at 16:10)</a>:</h4>
<p>hmm</p>



<a name="161461340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461340">(Mar 22 2019 at 16:10)</a>:</h4>
<p>I think you only get cat-rvalue <em>some</em> of the time</p>



<a name="161461349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461349">(Mar 22 2019 at 16:10)</a>:</h4>
<p>specifically, when there is an <code>Index</code> impl</p>



<a name="161461358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461358">(Mar 22 2019 at 16:10)</a>:</h4>
<p>do you also get it for indexing into a slice?</p>



<a name="161461367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461367">(Mar 22 2019 at 16:10)</a>:</h4>
<p>fair enough, only tried with vecs so far</p>



<a name="161461370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461370">(Mar 22 2019 at 16:10)</a>:</h4>
<p>put another way, we may not want to or be able to do better than that</p>



<a name="161461385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461385">(Mar 22 2019 at 16:11)</a>:</h4>
<p>I actually sort of forget what the RFC said here</p>



<a name="161461423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461423">(Mar 22 2019 at 16:11)</a>:</h4>
<p>but there is this question of when the code in the <code>Deref</code> or <code>Index</code> impl executes</p>



<a name="161461434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461434">(Mar 22 2019 at 16:11)</a>:</h4>
<p>at closure creation time -- or at closure execution time</p>



<a name="161461438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461438">(Mar 22 2019 at 16:11)</a>:</h4>
<p>actually, <em>indexing in particular</em> is tricky here</p>



<a name="161461443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461443">(Mar 22 2019 at 16:11)</a>:</h4>
<p>AFAIU, the RFC defines a minimal capture like I described, i.e. can't look past indexing, but still can determine something more accurate than <code>foo</code> in the above example</p>



<a name="161461447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461447">(Mar 22 2019 at 16:11)</a>:</h4>
<p>like, maybe the index doesn't exist yet :)</p>



<a name="161461500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461500">(Mar 22 2019 at 16:12)</a>:</h4>
<p>I see, I see, I didn't read closely enough</p>



<a name="161461543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461543">(Mar 22 2019 at 16:12)</a>:</h4>
<p>we may want to make a second path, similar to the one that builds cmts</p>



<a name="161461548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461548">(Mar 22 2019 at 16:12)</a>:</h4>
<p>sure, the issue here isn't about the indexing, I'm asking about the implementation for determining the path up to (but not including) the indexing</p>



<a name="161461554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461554">(Mar 22 2019 at 16:12)</a>:</h4>
<p>but taht does seem mildly unfortunate</p>



<a name="161461579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461579">(Mar 22 2019 at 16:13)</a>:</h4>
<p>yes, I understand better now</p>



<a name="161461585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461585">(Mar 22 2019 at 16:13)</a>:</h4>
<p>the problem is that the cmt is really oriented around the <em>final value</em></p>



<a name="161461590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461590">(Mar 22 2019 at 16:13)</a>:</h4>
<p>and what we need is more like "start from the beginning and work your way there"</p>



<a name="161461598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461598">(Mar 22 2019 at 16:13)</a>:</h4>
<p>yah</p>



<a name="161461623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461623">(Mar 22 2019 at 16:13)</a>:</h4>
<p>I'd have to look into the code</p>



<a name="161461632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461632">(Mar 22 2019 at 16:13)</a>:</h4>
<p>a bit more clsoely</p>



<a name="161461636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461636">(Mar 22 2019 at 16:13)</a>:</h4>
<p>that said, I'm trying to figure out if it would be simple enough to extend the <code>cmt_</code> to build up a chain in all cases we need</p>



<a name="161461664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461664">(Mar 22 2019 at 16:14)</a>:</h4>
<p>one option is, yes, to extend the cmt</p>



<a name="161461706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461706">(Mar 22 2019 at 16:14)</a>:</h4>
<p>the other would be to include enough info that we can re-create the cmt for the indexed path</p>



<a name="161461707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461707">(Mar 22 2019 at 16:14)</a>:</h4>
<p>no worries, hope I'll have a better understanding of the issues till tuesday</p>



<a name="161461717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461717">(Mar 22 2019 at 16:14)</a>:</h4>
<p>there is a slightly larger bit of context</p>



<a name="161461725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461725">(Mar 22 2019 at 16:14)</a>:</h4>
<p>in a side-table?</p>



<a name="161461730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461730">(Mar 22 2019 at 16:14)</a>:</h4>
<p>which is that, as the AST-based borrow check goes away,</p>



<a name="161461746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461746">(Mar 22 2019 at 16:14)</a>:</h4>
<p>we should be able to refactor the mem-categorization code heavily</p>



<a name="161461754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461754">(Mar 22 2019 at 16:14)</a>:</h4>
<p>unfortuantely it still has other uses</p>



<a name="161461760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461760">(Mar 22 2019 at 16:14)</a>:</h4>
<p>but basically I think it's due for a bit of a revamp</p>



<a name="161461802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461802">(Mar 22 2019 at 16:15)</a>:</h4>
<p>it will (afaik) only be used at that point to do upvar-capture-related computation</p>



<a name="161461807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461807">(Mar 22 2019 at 16:15)</a>:</h4>
<p>so we might want to just think about rewriting it</p>



<a name="161461826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461826">(Mar 22 2019 at 16:15)</a>:</h4>
<p>to be cleaner and to have these new goals in mind</p>



<a name="161461853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461853">(Mar 22 2019 at 16:15)</a>:</h4>
<p>and then the old mem-cat code can hang around and get "garbage collected" when the AST-based borrowck goes away</p>



<a name="161461859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461859">(Mar 22 2019 at 16:15)</a>:</h4>
<p>fair; not sure I grasp enough of the big picture yet to decide on whether this should be done as part of this implementation effort</p>



<a name="161461871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461871">(Mar 22 2019 at 16:15)</a>:</h4>
<p>but I'd want to check on whether there are other uses first, I may be forgetting something</p>



<a name="161461926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461926">(Mar 22 2019 at 16:16)</a>:</h4>
<p>at least one thing I can think of relates to generators</p>



<a name="161461945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161461945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161461945">(Mar 22 2019 at 16:16)</a>:</h4>
<p>(which is similar-<em>ish</em> to the upvar capture problem)</p>



<a name="161598769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161598769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161598769">(Mar 24 2019 at 21:58)</a>:</h4>
<p>Notes on reusing <code>mem_categorization.rs</code> for this:<br>
- recording the "previous" <code>cmt_</code> in the <code>Rvalue</code> seems to work in principle (when eyeballing the results; I'm sure there would be plenty of bugs to be found on closer examination)<br>
- a rudimentary sanity check of "did we record at least one path for each key in <code>upvar_capture_map</code>" doesn't trigger when building the compiler and going through the ui test suite. unfortunately can't go any further than that, as I based this exploration on the <code>upvar-tuple</code> branch, so there's some undiagnosed failures there</p>
<p>Another implementation issue lies around the corner: AFAIU, we need to track the minimal necessary access type per <code>(upvar, path) </code> (for this exploratory coding side-quest, I just separately stored the observed paths for each <code>UpvarId</code>). This would mean sticking the paths in <code>UpvarId</code>. <code>UpvarId</code>, however, needs to be <code>Copy</code> for a bunch of reasons, and the paths are dynamic both in number and in length.</p>
<p>What's more, if each <code>UpvarId</code> now contains a path (a path is currently a <code>Vec</code> of the provisionally named <code>CapturePathComponent</code>s), that'll probably require non-trivial modifications at every use site, roughly: (1) <code>expr_use_visitor..walk_captures</code> (2) <code>mem_categorization...cat_upvar</code> (3) hair conversion</p>



<a name="161598859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161598859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161598859">(Mar 24 2019 at 22:00)</a>:</h4>
<p>I should add that I'm going to have effectively zero time after May 1st, so I'm interested in making quick progress in this, if we can decide on the most promising implementation strategy (e.g. I'm open to trying my hand at a rewrite/fork of <code>cmt_</code> to narrow its scope)</p>



<a name="161726512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161726512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> blitzerr <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161726512">(Mar 26 2019 at 03:08)</a>:</h4>
<p><span class="user-mention" data-user-id="127677">@ange</span>  I am extremely sorry I have been distracted with travel and now something in day to day.</p>



<a name="161726587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161726587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> blitzerr <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161726587">(Mar 26 2019 at 03:10)</a>:</h4>
<p>If it is okay with you, can you please share your branch and then describe your problem/ concerns / approaches or proposals in a paper doc?<br>
Sometimes it better to read through a concise doc rather than chat messages back and forth or I will try to read the chat to understand</p>



<a name="161755851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/161755851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#161755851">(Mar 26 2019 at 12:25)</a>:</h4>
<p><span class="user-mention" data-user-id="128294">@blitzerr</span> no worries, I'm also on the road till thursday. I hope the comment above will be enough for today's discussion. started porting the exploratory code on top of latest master, but that's WIP that I won't have time to finish today</p>



<a name="162087576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/162087576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#162087576">(Mar 29 2019 at 22:08)</a>:</h4>
<p>started looking at the MIR side, to get some better understanding of how things fit together</p>



<a name="162087591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/162087591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#162087591">(Mar 29 2019 at 22:08)</a>:</h4>
<p>might inform implementation choices for how to record paths, etc</p>



<a name="162854536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/upvar%20path/near/162854536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ange <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/upvar.20path.html#162854536">(Apr 08 2019 at 20:58)</a>:</h4>
<p>FWIW, put up some notes on what I've been looking up <a href="https://paper.dropbox.com/doc/Upvar-Paths--Aa7C6aefXL6RNSXHuUu8jncVAg-PNRgk22ryKq1n3Wq3FXAO" target="_blank" title="https://paper.dropbox.com/doc/Upvar-Paths--Aa7C6aefXL6RNSXHuUu8jncVAg-PNRgk22ryKq1n3Wq3FXAO">here</a>. They refer to this <a href="https://github.com/aoikonomopoulos/rust/commits/throwaway-upvar-tuple" target="_blank" title="https://github.com/aoikonomopoulos/rust/commits/throwaway-upvar-tuple">exploratory branch</a> cc <span class="user-mention" data-user-id="128294">@blitzerr</span> <span class="user-mention" data-user-id="116773">@csmoe</span>  <span class="user-mention" data-user-id="116009">@nikomatsakis</span>, in case anyone wants to take a look</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>